# 导包
import time
from appium import webdriver
from appium.options.android import UiAutomator2Options
from selenium.webdriver.common.by import By

# 配置移动端设备信息
des_caps = {
    "platformName": "Android",  # 移动端系统平台
    "platformVersion": "12",  # 平台对应版本
    "deviceName": "mumu",  # 设备名称（可以随便写）
    "appPackage": "com.tpshop.malls",  # 包名
    "appActivity": ".SplashActivity"  # Activity页面名
}
# 初始化设备配置信息
option = UiAutomator2Options().load_capabilities(des_caps)
# 创建驱动对象
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", options=option)
time.sleep(4)
for i in range(3):
    driver.swipe(900, 1000, 100, 1000, 0)
driver.find_element(By.ID, "com.tpshop.malls:id/start_img").click()
time.sleep(1)
driver.find_element(By.XPATH, "//*[@text='我的']").click()
driver.tap([(53, 150), (176, 273)], 1000)
driver.find_element(By.XPATH, "//*[@text='请输入账号']").send_keys("18683060002")
driver.find_element(By.XPATH, "//*[@text='请输入密码']").send_keys("abc123")
driver.find_element(By.ID, "com.tpshop.malls:id/agree_btn").click()
driver.find_element(By.ID, "com.tpshop.malls:id/login_tv").click()



# 关闭驱动
time.sleep(3)
driver.quit()
